package top.mccat.filesystem.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.mccat.filesystem.bean.Account;
import top.mccat.filesystem.mapper.AccountMapper;
import top.mccat.filesystem.service.AccountService;

import java.util.List;

/**
 * @author Distance
 */
@Service
public class AccountServiceImpl implements AccountService {
    @Autowired
    private AccountMapper accountMapper;

    @Override
    public Account login(Account account) {
        return accountMapper.selectAccount(account);
    }

    @Override
    public boolean register(Account account) {
        return accountMapper.insertAccount(account) == 1;
    }

    /**
     * 列出所有账户
     *
     * @return 账户列表对象
     */
    @Override
    public List<Account> listAccounts(Account account) {
        return accountMapper.listAccounts(account);
    }

    /**
     * 更新账户
     *
     * @param account 用户对象
     * @return 是否更新成功
     */
    @Override
    public boolean updateAccount(Account account) {
        return accountMapper.updateAccount(account) > 0;
    }

    /**
     * 删除账户
     *
     * @param account 用户对象
     * @return 是否删除成功
     */
    @Override
    public boolean deleteAccount(Account account) {
        return accountMapper.deleteAccount(account) > 0;
    }

}
